package com.dckeji.shiplock.webapp.service.impl;

import com.dckeji.shiplock.framework.constants.SystemConstants;
import com.dckeji.shiplock.framework.util.DateTimeUtil;
import com.dckeji.shiplock.framework.util.StringUtil;
import com.dckeji.shiplock.webapp.dao.IPayDao;
import com.dckeji.shiplock.webapp.pojo.Pay;
import com.dckeji.shiplock.webapp.service.IPayService;
import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: TianWei
 * Date: 2017/8/8
 * Time: 11:49
 */
@Service
@Transactional
public class PayServiceImpl implements IPayService {

    @Value("${qiniu.domain}")
    String domain;
    @Autowired
    IPayDao payDao;

    @Override
    public int commitPayVoucher(String shipNo, String imgKey) {
        int updateRow = payDao.commitPayVoucher(shipNo, imgKey, DateTimeUtil.getSystemTime());
        return updateRow;
    }

    @Override
    public List<Pay> query(String shipNo, Integer status) {
        if (StringUtil.isNull(status)) {
            status = SystemConstants.OPT.WAIT_EXAMINE;
        }
        List<Pay> query = payDao.query(shipNo, status);

        return query;
    }

    @Override
    public List<Pay> queryAll() {


        return payDao.queryAll();
    }

    @Override
    public int payExamine(Integer declaId, Integer optType) {
        //修改审核状态
        int row = payDao.updatePayStatus(declaId, optType, DateTimeUtil.getSystemTime());
        if (row > 0) {

        }


        return 0;
    }
}
